import { defineStore } from "pinia";
import { UserState } from "@/stores/interface";
import piniaPersistConfig from "@/stores/helper/persist";

export const useUserStore = defineStore({
  id: "user",
  state: (): UserState => ({
    token: "",
    userInfo: {}
  }),
  getters: {
    getUserinfo: state => state.userInfo
  },
  actions: {
    setUserInfo(info: any) {
      this.token = info.token;
      this.userInfo = info;
    }
  },
  persist: piniaPersistConfig("user")
});
